<?php

// Configuration 
// Where is nexista? This path should be to a folder which contains a folder called "nexista"
$nexista_path = "/usr/share/php/";

$server_name = $_SERVER['SERVER_NAME'];
define('SERVER_NAME',$server_name);
$document_root = dirname(dirname(__FILE__));
define('PROJECT_ROOT',$document_root);
define('PROJECT_NAME','##PROJECT_NAME##');
define('APP_NAME','##APP_NAME##');

$server_init = PROJECT_ROOT."/cache/".SERVER_NAME."/".APP_NAME."/".APP_NAME.".php";
$app_sitemap = PROJECT_ROOT."/cache/".SERVER_NAME."/".APP_NAME."/sitemap.php";

if(!include(PROJECT_ROOT.'/lib/php/builder.php')) {
    echo "Error: Unable to load server loader or builder.";
    exit;
}

// Loader not there or manually getting rebuilt? Build it!
if(!file_exists($server_init) || !file_exists($app_sitemap) || $_GET['nxbin']) {
    build_it_now();
} else { // Loader is there, check freshness, then either rebuild or include it.
    check_freshness();
        include($server_init);
        exit;
}
